package com._dev.social.service.impl;


import com._dev.social.service.MinioService;
import com._dev.social.utils.MinioUtils;
import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @program: social_median_backend
 * @description:
 * @author: Mr.Liu
 * @create: 2024-11-01 22:00
 **/
@Service
public class MinioServiceImpl implements MinioService {

    @Resource
    private MinioUtils minioUtils;

    @Override
    public Boolean bucketExists(String bucketName) {
        return minioUtils.bucketExists(bucketName);
    }

    @Override
    public void makeBucket(String bucketName) {
        minioUtils.makeBucket(bucketName);
    }

    @SneakyThrows
    @Override
    public List<Object> listObjects(String bucketName) {
        return minioUtils.listObjects(bucketName);
    }

    @Override
    public Boolean upload(MultipartFile multipartFile) {
        return minioUtils.putObject(multipartFile);
    }

    @Override
    public void upload(MultipartFile[] multipartFile) {
        minioUtils.putObject(multipartFile);
    }

    @Override
    public Boolean deleteFile(String bucketName, String fileName) {
     return  minioUtils.removeObject(bucketName,fileName);
    }

    @Override
    public String getFileUrl(String fileName) {
        return minioUtils.getObjectUrl(fileName);
    }
}
